
package com.qdu.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
 *
 * @author Lenovo
 */

public class LoginOut1 extends HttpServlet{
    
	/**
	 * Constructor of the object.
	 */
	public LoginOut1() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		HttpSession session=request.getSession();
		String method=request.getParameter("method").trim();
		session.invalidate();
		//会员退出,跳到login.jsp页
		if(method.equals("user")){
			request.getRequestDispatcher("login.jsp").forward(request, response);
		}//管理员退出,跳到admin/login.jsp
		else if(method.equals("admin")){
			request.getRequestDispatcher("admin/login.jsp").forward(request, response);
		}
		else if(method.equals("center")){
			request.getRequestDispatcher("index.jsp").forward(request, response);
		}
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}
}
